package algorithm.arithmetic.重叠矩形;

import java.util.Arrays;
import java.util.Collections;

/**
 * @author 陶锦候
 */
public class Solution {
    private static class Inner {
        private boolean parallel;
        private double k1, k2, b1, b2, b3, b4;
        private double x1, y1, x2, y2, x3, y3;

        Inner(double x1, double y1, double x2, double y2, double x3, double y3) {
            if (x1 == x2 || x1 == x3) {
                parallel = true;
                this.x1 = x1;
                this.x2 = x2;
                this.x3 = x3;
                this.y1 = y1;
                this.y2 = y2;
                this.y3 = y3;
            } else {
                parallel = false;
                k1 = (y1 - y2) / (x1 - x2);
                k2 = (y1 - y3) / (x1 - x3);
                b1 = y1 - k1 * x1;
                b2 = y3 - k1 * x3;
                b3 = y2 - k2 * x2;
                b4 = y1 - k2 * x1;
            }
        }

        boolean innerp(double x, double y) {
            if (parallel) {
                if ((x >= x1 && x <= x2 && y >= y1 && y <= y3) ||
                        (x >= x1 && x <= x3 && y >= y1 && y <= y2)) {
                    return true;
                }
            } else {
                if (!(((y > (k1 * x + b1)) && (y > (k1 * x + b2))) ||
                        ((y < (k1 * x + b1)) && (y < (k1 * x + b2))) ||
                        ((y > (k2 * x + b3)) && (y > (k2 * x + b4))) ||
                        ((y < (k2 * x + b3)) && (y < (k2 * x + b4))))) {
                    return true;
                }
            }

            return false;
        }
    }

    private static double max(Double... x) {
        return Collections.max(Arrays.asList(x));
    }

    private static double min(Double... x) {
        return Collections.min(Arrays.asList(x));
    }

    public static void main(String[] args) {
        double ax1 = Integer.valueOf(args[0]), ay1 = Integer.valueOf(args[1]);
        double ax2 = Integer.valueOf(args[2]), ay2 = Integer.valueOf(args[3]);
        double ax3 = Integer.valueOf(args[4]), ay3 = Integer.valueOf(args[5]);

        double bx1 = Integer.valueOf(args[6]), by1 = Integer.valueOf(args[7]);
        double bx2 = Integer.valueOf(args[8]), by2 = Integer.valueOf(args[9]);
        double bx3 = Integer.valueOf(args[10]), by3 = Integer.valueOf(args[11]);

        double maxX = max(ax1, ax2, ax3, bx1, bx2, bx3, ay1, ay2, ay3, by1, by2, by3);
        double mixX = min(ax1, ax2, ax3, bx1, bx2, bx3, ay1, ay2, ay3, by1, by2, by3);

        Inner inner1 = new Inner(bx1, by1, bx2, by2, bx3, by3);
        Inner inner2 = new Inner(ax1, ay1, ax2, ay2, ax3, ay3);
        long sum = 0;

        double precision = 0.01;
        for (double i = mixX; i <= maxX; i += precision) {
            for (double j = mixX; j <= maxX; j += precision) {
                if (inner1.innerp(i, j) && inner2.innerp(i, j)) {
                    sum++;
                }
            }
        }
        System.out.println(Math.round(sum * precision * precision));
    }
}